/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2010-12-12
 * Time: 23:26:57
 * To change this template use File | Settings | File Templates.
 */
function getUploadFilePath(uploadType, uploadFile, randomKey) {

    var currentDate = new Date();
    var filePath = "uploads/" + uploadType + "/";
    var fileName = currentDate.getFullYear().toString().substr(2);
    ;
    if ((currentDate.getMonth() + 1) >= 10)
        fileName += (currentDate.getMonth() + 1);
    else
        fileName += "0" + (currentDate.getMonth() + 1);
    if (currentDate.getDate() >= 10)
        fileName += currentDate.getDate();
    else
        fileName += "0" + currentDate.getDate();
    fileName += "/" + fileName + randomKey;
    filePath += fileName + uploadFile.substr(uploadFile.lastIndexOf("."));
    return filePath
}

function getFileUrlFromCKFinder(fileControlId, imageControlId, fileType) {
    var uploadFileUrl = "";
    if (fileType == null)
        fileType = "images";
    var finder = new CKFinder();
    finder.ResourceType = fileType;
    finder.basePath = '/uploads/';	// The path for the installation of CKFinder (default = "/ckfinder/").
    finder.selectActionFunction = function(fileUrl) {
        uploadFileUrl = fileUrl;
        if (imageControlId != null)
            $("#" + imageControlId).attr("src", fileUrl);
        if (fileControlId != null)
            $("#" + fileControlId).val(fileUrl)

//            alert(fileUrl);
//            $f("player").stop();
        try {
            $f("player").play(fileUrl);
        }
        catch(e) {
        }
    };
    finder.popup();
    return uploadFileUrl;
}
//return "2010-03-21 04:05:06"
function getCurrentDateTimeStr() {
    var currentDate = new Date();
    var tempDate = currentDate.getFullYear() + "-";
    if ((currentDate.getMonth() + 1) < 10)
        tempDate += "0" + (currentDate.getMonth() + 1);
    else
        tempDate += currentDate.getMonth() + 1;
    tempDate += "-";
    if (currentDate.getDate() < 10)
        tempDate += "0" + currentDate.getDate();
    else
        tempDate += currentDate.getDate();
    tempDate += " ";
    if (currentDate.getHours() < 10)
        tempDate += "0" + currentDate.getHours() + ":";
    else
        tempDate += currentDate.getHours() + ":";

    if (currentDate.getMinutes() < 10)
        tempDate += "0" + currentDate.getMinutes() + ":";
    else
        tempDate += currentDate.getMinutes() + ":";

    if (currentDate.getSeconds() < 10)
        tempDate += "0" + currentDate.getSeconds();
    else
        tempDate += currentDate.getSeconds();
    return tempDate;
}

function onTdClick(trId, preTr, flag) {
    if ($("#" + trId).css("display") == "none") {
        $("#" + trId).css("display", "block");
        if (flag == null) {
            $("#" + preTr).removeClass("menu1");
            $("#" + preTr).addClass("menu2");
        }
        else {
            $("#" + preTr).removeClass("menu3");
            $("#" + preTr).addClass("menu4");
        }
    }
    else {
        $("#" + trId).css("display", "none");
        if (flag == null) {
            $("#" + preTr).removeClass("menu2");
            $("#" + preTr).addClass("menu1");
        }
        else {
            $("#" + preTr).removeClass("menu4");
            $("#" + preTr).addClass("menu3");
        }
    }
}

